# # def compare_evaluate_result(left, right):
# #     lmae, lmse, lrmse, rmae, rmse, rrmse = left[0], left[1], left[2], right[0], right[1], right[2]
# #     if lmse < rmse:
# #         if lmae < rmae:
# #             return True
# #         else:
# #             if rmse - lmse >= lmae - rmae:
# #                 return True
# #             else:
# #                 return False
# #     else:
# #         if lmae > rmae:
# #             return False
# #         else:
# #             if lmse - rmse >= rmae - lmae:
# #                 return False
# #             else: 
# #                 return True
# def compare_evaluate_result(left, right):
#     """比较两个结果列表的优劣"""
#     lmae, lmse, lrmse, rmae, rmse, rrmse = left[0], left[1], left[2], right[0], right[1], right[2]
#     if lmse < rmse:
#         if lmae < rmae:
#             return -1
#         else:
#             return -1 if (rmse - lmse >= lmae - rmae) else 1
#     else:
#         if lmae > rmae:
#             return 1
#         else:
#             return 1 if (lmse - rmse >= rmae - lmae) else -1

# names_list = []
# with open(f'random_data.txt', mode='r', encoding='utf-8') as file:
#     lines = file.readlines()
#     one_name_list = []
#     for line in lines:
#         row = line.strip()
#         if not row:
#             names_list.append(one_name_list)
#             one_name_list = []
#         else:
#             one_name_list.append(row)
# print(len(names_list))
# ans_list = []
# with open(f'/home/n40/code/aesthetic_path/AL_MRL/result/CNN_USE_TRANSFORM_new.txt', mode='r', encoding='utf-8') as file:
#     lines = file.readlines()
#     result_list = [100 for _ in range(8)]
#     for line in lines:
#         row = line.strip().split()
#         if len(row) == 8:
#             numbers = [round(float(num), 4) for num in row]
#             if compare_evaluate_result(numbers, result_list) < 0:
#                 result_list = numbers
#         else:
#             ans_list.append(result_list)
#             result_list = [100 for _ in range(7)]


# # name_to_result = [[names_list[_], ans_list[_]] for _ in range(len(names_list))]
# from functools import cmp_to_key
# from random import sample
# def compare_indexed_results(x, y):
#     """包装索引和比较函数"""
#     return compare_evaluate_result(x[1], y[1])
# indexed_ans_list = list(enumerate(ans_list))
# sorted_indexed_ans_list = sorted(indexed_ans_list, key=cmp_to_key(compare_indexed_results))

# # 提取排序后的下标
# sorted_indices = [item[0] for item in sorted_indexed_ans_list][::-1]
# # print(sorted_indices)
# for idx in range(len(sorted_indices)):
#     sampleData = []
#     for name in names_list[sorted_indices[idx]]:
#         sampleData.append(name)
#     print(f'sampleData is {sampleData}')
#     print(f'ans_list is {ans_list[sorted_indices[idx]]}')
# # sorted_data = sorted(name_to_result, key=lambda x : (x[1][1], x[1]))
# # print(len(ans_list))
# # print(ans_list)

# if self.opt.Save_dimension_chosen_nums == str('true'):
# train_agents = {}
# train_agents['dimension_chosen_nums'] = [0 for _ in range(77)]
# with open(f"/home/n40/code/aesthetic_path/AL_MRL/dimension_chosen_nums.txt", mode='a', encoding='utf-8') as file:
#     for idx in range(77):
#         ke = str('dimension_chosen_nums')
#         file.write(str(f'{idx} {train_agents[ke][idx]}'))
#         file.write('\n')